home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / SORTDEMO.ARJ / SORTDEMO.DOC < prev    next >
Text File  |  1992-04-18  |  10KB  |  206 lines

  1.  
  2.                                    SORTDEMO
  3.                                    ver 1.0
  4.  
  5.                               by Jon S. Russell
  6.  
  7.  
  8. -----------------------------------------------------------------------------
  9.  
  10. HARDWARE REQUIREMENTS:
  11.  
  12.   SORTDEMO requires an IBM compatible computer with
  13.   VGA graphics capabilities, and 640k memory.
  14.  
  15. -----------------------------------------------------------------------------
  16.  
  17. MANIFEST:
  18.   These files should be included with the SORTDEMO package.
  19.  
  20.     SORTDEMO.EXE .. executable program
  21.     SORTDEMO.DOC .. this file (documentation)
  22.     SORTDEMO.PAS .. Turbo Pascal source file
  23.     SDGRAF  .INC .. Turbo Pascal include file (basic graphics routines)
  24.     SDKEY   .INC .. Turbo Pascal include file (keyboard routines)
  25.     SDTIME  .INC .. Turbo Pascal include file (time-keeping routines)
  26.     SDFILE  .INC .. Turbo Pascal include file (file-related routines)
  27.     SDDISP  .INC .. Turbo Pascal include file (info-display/menuing routines)
  28.     SDMISC  .INC .. Turbo Pascal include file (misc routines)
  29.     SDSORT01.INC .. Turbo Pascal include file (Bubble Sort routine)
  30.     SDSORT02.INC .. Turbo Pascal include file (Short-Bubble Sort routine)
  31.     SDSORT03.INC .. Turbo Pascal include file (Selection Sort routine)
  32.     SDSORT04.INC .. Turbo Pascal include file (Merge Sort routine)
  33.     SDSORT05.INC .. Turbo Pascal include file (QuickSort #1 routine)
  34.     SDSORT06.INC .. Turbo Pascal include file (QuickSort #2 routine)
  35.     SDSORT07.INC .. Turbo Pascal include file (Heap Sort routine)
  36.     REGISTER.FRM .. Registration form (ASCII text)
  37.     VGA256  .BGI .. Borland's VGA mode 13h driver (rqrd for SORTDEMO to work)
  38.  
  39.   If any of these files are missing, contact the author, (Jon Russell) via
  40.  
  41.     THE DREAMWEAVER BBS  2400 8/N/1  @ 817-668-1375.
  42.  
  43.   This is a new BBS as of 1992 and at the time of this release is operating
  44.   from 7:00pm to midnight weekdays and 24hrs on weekends.
  45.  
  46. -----------------------------------------------------------------------------
  47.  
  48. OPERATION:
  49.  
  50.   Running SORTDEMO is pretty simple, upon starting the program a title
  51.   screen is displayed, simply press any key to go to the main menu.
  52.   Using the menu requires that you select the desired settings by using
  53.   the left and right arrow keys to move the highlighted area title and the
  54.   up and down arrow keys to select the desired setting.  Pressing enter at
  55.   any time the menu is displayed will execute the function defined by the
  56.   Operation slider using the parameters defined by the other areas.
  57.  
  58.   The layout of the menu is something like this...
  59.  
  60.  
  61.     <X-size>   <Y-size>   <Method>             <Stats file>
  62.      ■  20      ■  1       ■  Bubble Sort          yes
  63.         40         2          Short Bubble      ■  no
  64.         80         4          Selection Sort
  65.        160         5          Merge Sort       <Operation>
  66.                    8          QuickSort #1      ■  mix
  67.                   10          QuickSort #2         sort
  68.                   20          Heap Sort            quit
  69.                   25
  70.                   50
  71.  
  72.       Array size:  xxxx        Array status: sorted
  73.  
  74.  
  75.   <X-size>     selects the number of colored blocks across the screen.
  76.   <Y-size>     selects the number of colored blocks up and down the screen.
  77.   <Method>     selects the sorting routine to use.
  78.   <Stats file> toggles piping of the analysis information to a text file
  79.                named SDSTATS.DAT.  (This file may be viewed with any text
  80.                viewer or editor).
  81.   <Operation>  selects the next operation to execute.
  82.  
  83.  
  84.   Next to each of the areas there is a slider bar showing the current
  85.   selection of that area.  Using the left/right arrow keys, move to the
  86.   X-size and Y-size areas to select the size of the array to be sorted,
  87.   notice that the Array size shown below is updated each time the sliders
  88.   on X-size or Y-size are moved.  (The array size is calculated by
  89.   X-size * Y-size).  With the Operation slider pointing to mix, press the
  90.   enter key.  The menu will disappear and a graphical representation of
  91.   the array will be shown such that there are X-size blocks across the
  92.   screen and Y-size blocks up and down the screen.  The blocks are initially
  93.   arranged so that their colors are ordered by columns.  The mix routine
  94.   starts swapping color blocks thus mixing the array.  When you feel the
  95.   array is sufficiently mixed, press any key and you will go back to the
  96.   menu screen.  Notice that the Array status now shows the array to be
  97.   unsorted.  Now use the up/down arrow keys to move the Operation slider
  98.   to sort, then use the left/right arrow keys to move the current area to
  99.   <Method> and use the up/down arrow keys to select a sorting method.  Press
  100.   enter when you have done this, and the colored blocks will reappear back
  101.   on the screen as they were when you finished mixing them.  The selected
  102.   sort routine will immediately take over and sort the colored blocks back
  103.   to their orginal order, (all columns of the same color).  When the sorting
  104.   routine is finished, an Analysis screen is displayed.  The analysis screen
  105.   simply displays some information about the sort just completed, ie the
  106.   sort method used, the size of the array sorted, time started and stopped,
  107.   and the length of time required to complete the sort.  Note that if the
  108.   <Stats file> slider were set to yes, this information would also be saved
  109.   to a text file named SDSTATS.DAT.  When you are done reading the analysis,
  110.   press any key to return to the menu screen and change the array size or
  111.   the sorting method, remix and resort, etc.
  112.  
  113. -----------------------------------------------------------------------------
  114.  
  115. ABOUT SORTDEMO:
  116.  
  117.   The sorting routines presented here (in the files SDSORT0?.INC) are
  118.   not written for maximum speed, some performance was traded for ease
  119.   of understanding/clairity.  If you were to modify these routines for use
  120.   in your own programs and wanted to make them as fast as possible,
  121.   I would suggest (for starters) doing things like rewritting the sort
  122.   routine so that there were no internal procedure/function calls.  Make
  123.   the routine as self contained as possible.  For example instead of calling
  124.   a procedure such as Swap(a,b);  replace any calls with something like...
  125.  
  126.     Temp := a;
  127.     a := b;
  128.     b := temp;
  129.  
  130.   Do the same with as many other calls as possible.  Another way to speed
  131.   up sorting routines is to sort pointers to the appropriate records as
  132.   opposed to sorting the records themselves.  This can be a substantial
  133.   improvement especially if your data records are large.  It takes the
  134.   computer much less time (and memory) to exchange pointer values than it
  135.   would to exchange a data record like...
  136.  
  137.   EmployeeType = record
  138.                    FirstName : string;
  139.                    LastName  : string;
  140.                    ID_Num    : integer;
  141.                    HireDate  : DateType;
  142.                    .
  143.                    .
  144.                    .
  145.                  end;
  146.  
  147.   Selection of the proper sorting technique is essential to any program
  148.   that requires efficient performance.  For example, the bubble sort is
  149.   better when working with small arrays than the merge sort, but if working
  150.   with larger arrays, the merge sort technique more than doubles the memory
  151.   requirements.  The short bubble sort is usually pretty efficient if only
  152.   a small number of elements are out of order, while the heap sort is only
  153.   efficient when working with arrays that are thoroughly mixed up.  Use
  154.   SORTDEMO to experiment with sorting various sized arrays and sorting
  155.   arrays only slightly out of order or try to sort an array that is already
  156.   sorted.  You may find the results quite suprising.
  157.  
  158.   The sorting methods presented here are by no means all of the techniques
  159.   available, I have just implemented a few of the more popular ones.  I have
  160.   attempted to write SORTDEMO in such a manner that it would be fairly easy
  161.   for you to try out other techniques.  Just write your own routine as
  162.   an include file, and substitute if for the appropriate include file (ie
  163.   SDSORT01), and recompile.
  164.  
  165. -----------------------------------------------------------------------------
  166.  
  167. REGISTRATION:
  168.  
  169.   Registration for SORTDEMO is $10.00.  If you find SORTDEMO of use, please
  170.   register it.  I am currently working on a program that will graphically
  171.   explain in depth how various sorting routines work.  Registering SORTDEMO
  172.   will get you a copy of this program.  To register, print out the text file
  173.   REGISTER.FRM, complete all applicable information, and mail it to:
  174.  
  175.     Jon Russell
  176.     1511 Mill
  177.     Gainesville, TX  76240
  178.  
  179.   Your registration fee will help me to contend with the rising cost of
  180.   education.  I am currently studying Computer Science at the University
  181.   of North Texas.
  182.  
  183. -----------------------------------------------------------------------------
  184.  
  185. CREDITS:
  186.  
  187.   Turbo Pascal is a product of Borland International.
  188.  
  189.   SORTDEMO was developed with Turbo Pascal 6.0 but the source code
  190.   "should" compile with Turbo Pascal 5.0 and 5.5 also.
  191.  
  192.   The sort routines used here were modified from the book
  193.   "Pascal Plus Data Structures" by Nell Dale & Susan C. Lilly.
  194.  
  195. -----------------------------------------------------------------------------
  196.  
  197. DISCLAIMER:
  198.  
  199.   This product is distributed AS IS.  The author specifically disclaims
  200.   all warrienties, expressed or implied, including but not limited to
  201.   implied warranties of merchantability and fitness for a particular
  202.   purpose.  In no event shall the author be liable for any loss of profit
  203.   or any other commercial damage including but not limited to special,
  204.   incidental, consequential or other damages.
  205.  
  206.